Skip to content

fix(preview): name hidden, disabled, and ambiguous click failures - #7301

Open
gbarros-dev wants to merge 8 commits into
pingdotgg:mainfrom
gbarros-dev:fix/preview-click-error-kinds
Open

fix(preview): name hidden, disabled, and ambiguous click failures#7301
gbarros-dev wants to merge 8 commits into
pingdotgg:mainfrom
gbarros-dev:fix/preview-click-error-kinds

Conversation

@gbarros-dev

@gbarros-dev gbarros-dev commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

preview_click identified hidden, disabled, and ambiguous targets in the desktop process, but Electron IPC did not preserve the custom error fields. The MCP caller then received a generic client failure.

This change sends a typed click outcome across Electron IPC. The web host returns only the exact lookup reason and optional match count. The broker combines that response with the selector kind and length from the original request, so the MCP error is useful without returning the locator text.

The desktop action timeline still records target lookup failures as failed clicks.

Related to #3714. Does not close it.

Tests:

  • vp test run packages/contracts/src/ipc.test.ts
  • vp test run apps/desktop/src/preview/Manager.test.ts apps/desktop/src/ipc/methods/preview.test.ts
  • vp test run apps/web/src/components/preview/previewAutomationErrors.test.ts apps/web/src/components/preview/previewAutomationRequestConsumer.test.ts
  • vp test run apps/server/src/mcp/PreviewAutomationBroker.test.ts apps/server/src/mcp/McpHttpServer.test.ts

Original implementation by @gbarros-dev with Grok 4.6 through Grok CLI.

Made with GPT-5.6 Sol using Codex for modernization.


Note

Medium Risk
Changes preview automation click semantics and error propagation across desktop IPC, web host, and MCP; callers that assumed silent success on lookup failure now get typed failures, but successful clicks still dispatch input as before.

Overview
Preview automation clicks now return a typed DesktopPreviewAutomationClickResult over Electron IPC (Dispatched or NotSent with reasons like target-missing, target-hidden, target-disabled, target-ambiguous) instead of void, so lookup failure details are not lost before they reach MCP callers.

On the desktop side, locator resolution uses all matches and classifies missing, hidden, disabled, and ambiguous targets; failed lookups yield NotSent without dispatching mouse input, while the action timeline still records failed clicks. New PreviewAutomationTargetLookupError types (contracts, desktop manager, web host) carry failureKind and optional matchCount, with messages that avoid leaking locator text.

The web preview host wraps IPC results with confirmPreviewAutomationClickTarget, turning target NotSent outcomes into PreviewAutomationTargetLookupHostError for the automation broker/MCP path. The server broker maps remote lookup errors from response detail.failureKind.

Reviewed by Cursor Bugbot for commit 30f017d. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Return typed click outcomes for preview automation clicks

  • Preview automation clicks now return DesktopPreviewAutomationClickResult with Dispatched or NotSent variants (target-missing, target-hidden, target-disabled, target-ambiguous) instead of void
  • PreviewManager locator lookup switches from single-element to all-matches query so ambiguous targets with multiple matches are detected; only a single visible enabled match is clicked
  • New schema-backed error classes (PreviewAutomationTargetLookupError, PreviewAutomationTargetLookupHostError) carry the lookup failure kind and optional positive match count, with sanitized messages that omit selector/locator values
  • The web preview host converts every NotSent click result into a named host automation error via confirmPreviewAutomationClickTarget
  • Behavioral Change: DesktopPreviewBridge.automation.click return type changes from Promise<void> to Promise<DesktopPreviewAutomationClickResult | void>; callers that ignored the result are unaffected, but the broker and host layers now reject NotSent outcomes as errors rather than silently succeeding

Macroscope summarized 30f017d.

@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Aug 17, 2026
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 438ef4e0-9982-4cbd-8b1f-40df040e76d7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the size:L 100-499 changed lines (additions + deletions). label Aug 17, 2026

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One finding on the desktop-side error construction. See the inline comment.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/preview/Manager.ts Outdated
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Aug 17, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at a46cbf3

Macroscope's review found this PR approvable — This is a focused preview-click failure-handling fix that preserves successful click behavior while carrying missing, hidden, disabled, and ambiguous outcomes through the existing IPC, web, and MCP layers. The contract changes are additive and the new paths have targeted coverage, with locator text kept out of surfaced errors.

You can add or adjust custom eligibility rules. Learn more.

@gbarros-dev
gbarros-dev force-pushed the fix/preview-click-error-kinds branch from bc897ad to 698bda4 Compare August 17, 2026 08:34
@macroscopeapp
macroscopeapp Bot dismissed their stale review August 17, 2026 08:34

Dismissing prior approval to re-evaluate 698bda4

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the new preview automation lookup error classes against the Effect service conventions. The desktop-side classification is now a static factory next to the error type (PreviewAutomationTargetNotFoundError.fromLookupFailure), the new errors are structured Schema.TaggedErrorClass variants with messages derived from attributes, no selector text is leaked, and the host-side wrappers preserve cause. One finding: a redundant failureKind discriminator path on the web translation boundary that nothing produces.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/web/src/components/preview/previewAutomationErrors.ts Outdated
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Aug 17, 2026
@t3dotgg
t3dotgg force-pushed the fix/preview-click-error-kinds branch from a149228 to b322990 Compare September 1, 2026 23:41
@macroscopeapp
macroscopeapp Bot dismissed their stale review September 1, 2026 23:41

Dismissing prior approval to re-evaluate b322990

Comment thread apps/desktop/src/preview/Manager.ts Outdated
Comment thread apps/desktop/src/preview/Manager.ts Outdated
Comment thread apps/desktop/src/preview/Manager.ts Outdated
@t3dotgg
t3dotgg force-pushed the fix/preview-click-error-kinds branch from 5366027 to f5145de Compare September 2, 2026 00:00
Comment thread apps/web/src/components/preview/previewAutomationErrors.ts Outdated
@t3dotgg
t3dotgg force-pushed the fix/preview-click-error-kinds branch from a46cbf3 to def8129 Compare September 2, 2026 01:11
@gbarros-dev
gbarros-dev force-pushed the fix/preview-click-error-kinds branch from def8129 to 0437863 Compare September 3, 2026 09:30
gbarros-dev and others added 8 commits September 3, 2026 12:12
preview_click treated a hidden or disabled button as missing and leaked
the locator when it failed. Agents then spent turns guessing at chrome
they could already see.

Clicks now report hidden, disabled, or ambiguous targets without putting
the locator on the wire.
A free function picked hidden/disabled/ambiguous and defaulted
ambiguous matches to 0. The policy now lives on
PreviewAutomationTargetNotFoundError.fromLookupFailure, and
ambiguous requires an explicit match count.
Host mapping still accepted a failureKind field on
PreviewAutomationTargetNotFoundError. Nothing emits that shape.
Classification now uses the hidden, disabled, and ambiguous tags only.
@gbarros-dev
gbarros-dev force-pushed the fix/preview-click-error-kinds branch from 0437863 to 30f017d Compare September 3, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants